// pages/showTicket/showTicket.js
Page({
  data: {
    sourceTtime: '',
    dstTime: '',
    date: '',
    array: '0'
  },
  onLoad: function (options) {

  },

  onShow: function () {
    wx.request({
      url: 'http://localhost:8080/TrainManager/SelectTicket',
      data:{
        source: getApp().globalData.source,
        dst: getApp().globalData.dst,
        flag: 0,
        ticketMes: [{}]
      },

      success: (res) => {

        if(res.data[0].flag == 1) {
          this.setData({
            massage: res.data,
            date: getApp().globalData.datee
          })
        }
        else {
          wx.showToast({
            title: '无数据',
            duration: 1000,
            image: '/images/x1.png',
            success: function(){
              setTimeout( function(){
                wx.navigateBack({
                  delta: 1,
                })
              }, 1000)
            }
          })
        }
      }
    })
  },

  clickViewAction: function(e) {
    this.setData({
      id: e.currentTarget.dataset.id
    })
    getApp().globalData.id = this.data.id;

    wx.navigateTo({
      url: '/pages/buyTicket/buyTicket',
    })
  }
})